# Snippets used by Eikos Risk Applications to accelerate ASPX page generation 
# for Eikos Online Applications

# Snippets
# --------

# Typically the top line, wiring the XML front-end file and code behind file
# together.
snippet aspxdirective 
	<%@ Page Language="vb" AutoEventWireup="false" Codefile="${1:`substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", "")`}.aspx.vb" SRC="${2:../}EOACore.vb" Inherits="$1" %>


# Simple ASPX elements
# General Control
	<asp:${1:Panel} runat="server" id="${2:pnlError}" CssClass="${3:ErrorDiv}"></asp:$1>

# General purpose control
snippet aspx Control
	<asp:${1:ControlType} id="${2:ControlName}" runat="server" CssClass="${3:CssClass}"></asp:$1>

# Drop-down lists
snippet aspx Drop-down list (hard-coded)
	<asp:DropDownList id=ddl${1:ControlName} runat="server" CssClass="combobox" DataValueField="${2:ValueField}" DataTextField="${3:TextField}" DataMember="dt${4:DataTable}" DataSource="<%# dt${5:$4} %>">
		<asp:ListItem Value="${6}">${7}</asp:ListItem>
	</asp:DropDownList>

snippet aspx Drop-down list (data bound)
	<asp:DropDownList id=ddl${1:ControlName} runat="server" CssClass="combobox" DataValueField="${2:ValueField}" DataTextField="${3:TextField}" DataMember="dt${4:DataTable}" DataSource="<%# dt${5:$4} %>">
	</asp:DropDownList>

# Textboxes
snippet aspx Textbox
	<asp:Textbox id="txt${1:ControlName}" runat="server" CssClass="textbox" Text="" MaxLength="${2:30}"></asp:Textbox>
	<asp:RegularExpressionValidator id="valRegex$1" runat="server" Type="Text" 
		ControlToValidate="txt$1"  Display="Dynamic" ValidationExpression=".{$2}" 
		ErrorMessage="<BR>Please enter a maximum of $2 characters.">
	</asp:RegularExpressionValidator>

snippet aspx Textbox (Required)
	<asp:Textbox id="txt${1:ControlName}" runat="server" CssClass="textbox" Text="" MaxLength="30"></asp:Textbox>
	<asp:RequiredFieldValidator id="valReq$1" runat="server" ControlToValidate="txt$1" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a $2"></asp:RequiredFieldValidator>
	<asp:RegularExpressionValidator id="valRegex$1" runat="server" Type="Text" 
		ControlToValidate="txt$1"  Display="Dynamic" ValidationExpression=".{$2}" 
		ErrorMessage="<BR>Please enter a maximum of $2 characters.">
	</asp:RegularExpressionValidator>

snippet aspx Textbox (Date)
	<asp:Textbox id="txt${1:ControlName}" runat="server" CssClass="textbox" Text=""></asp:Textbox>
	<asp:RequiredFieldValidator id="valReq$1" runat="server" ControlToValidate="txt$1" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a valid date (dd/mm/yyyy)"></asp:RequiredFieldValidator>
	<asp:RangeValidator id="valRange$1" runat="server" Type="Date" ControlToValidate="txt$1" MinimumValue="01/01/1753" MaximumValue="31/12/9999" Display="Dynamic" ErrorMessage="<BR>Please enter a valid date (dd/mm/yyyy)"></asp:RangeValidator>

snippet aspx Textbox (Currency - Positive)
	<asp:Textbox id="txt${1:ControlName}" runat="server" CssClass="textbox" Text=""></asp:Textbox>
	<asp:RequiredFieldValidator id="valReq$1" runat="server" ControlToValidate="txt$1" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a positive numerical value"></asp:RequiredFieldValidator>
	<asp:RangeValidator id="valRange$1" runat="server" Type="Currency" ControlToValidate="txt$1" MinimumValue="0" MaximumValue="${2:79228162514264337593543950335}" Display="Dynamic" ErrorMessage="<BR>Please enter a positive numerical value"></asp:RangeValidator>

snippet aspx Textbox (Currency - Negative and Positive)
	<asp:Textbox id="txt${1:ControlName}" runat="server" CssClass="textbox" Text=""></asp:Textbox>
	<asp:RequiredFieldValidator id="valReq$1" runat="server" ControlToValidate="txt$1" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a numerical value"></asp:RequiredFieldValidator>
	<asp:RangeValidator id="valRange$1" runat="server" Type="Currency" ControlToValidate="txt$1" MinimumValue="${2:-79228162514264337593543950335}" MaximumValue="${3:79228162514264337593543950335}" Display="Dynamic" ErrorMessage="<BR>Please enter a numerical value"></asp:RangeValidator>

# Form composites
# Standard input on forms
snippet trfield Drop-down list
	<TR>
		<TD CLASS="fieldcell">${1:Name}</TD>
		<TD CLASS="inputcell">
			<asp:DropDownList id=ddl${2:ControlName} runat="server" CssClass="combobox" DataValueField="${3:ValueField}" DataTextField="${4:TextField}" DataMember="dt${5:DataTable}" DataSource="<%# dt${6:$5} %>"></asp:DropDownList>
		</TD>
	</TR>

# Standard input on forms
snippet trfield Textbox
	<TR>
		<TD CLASS="fieldcell">${1:Name}</TD>
		<TD CLASS="inputcell">
			<asp:Textbox id="txt${2:ControlName}" runat="server" CssClass="textbox" Text=""></asp:Textbox>
			<asp:RequiredFieldValidator id="valReq$2" runat="server" ControlToValidate="txt$2" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a $1"></asp:RequiredFieldValidator>
		</TD>
	</TR>

# Standard input on forms
snippet trfield Textbox - Date
	<TR>
		<TD CLASS="fieldcell">${1:Name}</TD>
		<TD CLASS="inputcell">
			<asp:Textbox id="txt${2:ControlName}" runat="server" CssClass="textbox" Text=""></asp:Textbox>
			<asp:RequiredFieldValidator id="valReq$2" runat="server" ControlToValidate="txt$2" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a valid date (dd/mm/yyyy)"></asp:RequiredFieldValidator>
			<asp:RangeValidator id="valRange$2" runat="server" Type="Date" ControlToValidate="txt$2" MinimumValue="01/01/1753" MaximumValue="31/12/9999" Display="Dynamic" ErrorMessage="<BR>Please enter a valid date (dd/mm/yyyy)"></asp:RangeValidator>
		</TD>
	</TR>

# Standard input on forms
snippet trfield Textbox - Currency (Positive)
	<TR>
		<TD CLASS="fieldcell">${1:Name}</TD>
		<TD CLASS="inputcell">
			<asp:Textbox id="txt${2:ControlName}" runat="server" CssClass="textbox" Text=""></asp:Textbox>
			<asp:RequiredFieldValidator id="valReq$2" runat="server" ControlToValidate="txt$2" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a positive numerical value"></asp:RequiredFieldValidator>
			<asp:RangeValidator id="valRange$2" runat="server" Type="Currency" ControlToValidate="txt$2" MinimumValue="0" MaximumValue="${3:79228162514264337593543950335}" Display="Dynamic" ErrorMessage="<BR>Please enter a positive numerical value"></asp:RangeValidator>
		</TD>
	</TR>

# Standard input on forms
snippet trfield Textbox - Currency (All)
	<TR>
		<TD CLASS="fieldcell">${1:Name}</TD>
		<TD CLASS="inputcell">
			<asp:Textbox id="txt${2:ControlName}" runat="server" CssClass="textbox" Text=""></asp:Textbox>
			<asp:RequiredFieldValidator id="valReq$2" runat="server" ControlToValidate="txt$2" InitialValue="" Display="Dynamic" ErrorMessage="<BR>Please enter a numerical value"></asp:RequiredFieldValidator>
			<asp:RangeValidator id="valRange$2" runat="server" Type="Currency" ControlToValidate="txt$2" MinimumValue="${3:-79228162514264337593543950335}" MaximumValue="${4:79228162514264337593543950335}" Display="Dynamic" ErrorMessage="<BR>Please enter a numerical value"></asp:RangeValidator>
		</TD>
	</TR>

# Datagrid Elements
# Button Column
snippet dg ButtonColumn
	<asp:ButtonColumn HeaderText="${1:HeaderText}" CommandName="${2:Select}" Text="${3:Select}"></asp:ButtonColumn>

# Bound Column
snippet dg BoundColumn
	<asp:BoundColumn DataField="${1:DescriptionColumn}" SortExpression="$1" ReadOnly="True" HeaderText="${2:Description}">
		<HeaderStyle Wrap="False"></HeaderStyle>
		<ItemStyle Wrap="False"></ItemStyle>
	</asp:BoundColumn>

# Full Datagrid
snippet dg DataGrid
	<asp:DataGrid id="DG$1" runat="server" CssClass="grid" Width="80%" DataKeyField="ID" 
		AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" HorizontalAlign="Center" PageSize="20">
		<FooterStyle CssClass="GridFooter"></FooterStyle>
		<AlternatingItemStyle CssClass="GridAlternatingItem"></AlternatingItemStyle>
		<ItemStyle CssClass="GridItem"></ItemStyle>
		<HeaderStyle CssClass="GridHeader"></HeaderStyle>
		<PagerStyle CssClass="gridpager" PrevPageText="&lt; Previous " NextPageText=" Next &gt;"></PagerStyle>
		<Columns>
			<asp:ButtonColumn Text="Select" CommandName="Select"></asp:ButtonColumn>
			<asp:BoundColumn DataField="${2:DescriptionColumn}" SortExpression="$2" ReadOnly="True" HeaderText="${3:Description}">
				<HeaderStyle Wrap="False"></HeaderStyle>
				<ItemStyle Wrap="False"></ItemStyle>
			</asp:BoundColumn>
		</Columns>
	</asp:DataGrid>

# Templates
# ---------

# A basic web page, no specific purpose.
snippet page Basic page
	<%-- Page Language="vb" AutoEventWireup="false" Codebehind="${1:`substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", "").".aspx.vb"`}" Inherits="eikosonline.net.${2:`substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", "")`}" --%>
	<%@ Page Language="vb" AutoEventWireup="false" Codefile="$1" Inherits="$2" %>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" >
	<head runat="server">
		<title>${2:PageTitle}</title>
		<LINK HREF="${3:../}Styles.CSS" type="text/css" rel="stylesheet">
	</head>
	<body>
		<form id="form1" runat="server">
		<div>
			<asp:Panel id="pnlError" runat="server" Visible="False">
				<TABLE class="formtable" id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="1">
				<TR>
					<TD class="ValidationMessage" style="TEXT-ALIGN: center">
						<asp:Label id="lblError" runat="server" ForeColor="Red"></asp:Label>
					</TD>
				</TR>
				</TABLE>
			</asp:Panel>
			<asp:Panel id="pnlAll" runat="server">
				${}
			</asp:Panel>
		</div>
	</form>
	</body>
	</html>

# List page template - displays a datagrid that should redirect to the entity"s 
# detail frameset.
snippet page List page
	<%-- Page Language="vb" AutoEventWireup="false" Codebehind="${1:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "list$", "List", "").".aspx.vb"`}" Inherits="eikosonline.net.${2:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "list$", "List", "")`}" --%>
	<%@ Page Language="vb" AutoEventWireup="false" Codefile="$1" Inherits="$2" %>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
	<HTML>
	<HEAD>
		<TITLE>${3:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "list$", "List", "")`}s</TITLE>
		<LINK HREF="${4:../}Styles.CSS" type="text/css" rel="stylesheet">
	</HEAD>
	<BODY CLASS="centertext">
	<FORM ID="Form1" method="post" runat="server">
		<H1>${5:Entities} List</H1>
		<asp:Panel id="pnlError" runat="server" align="center" Class="ErrorDiv" Visible="False">
			<asp:Label id="lblError" runat="server" ForeColor="Red"></asp:Label>
		</asp:Panel>
		<asp:Panel id="pnlAll" runat="server">
			<asp:Panel id="pnlListForm" runat="server">
				<TABLE class="formtable" id="Table1" cellSpacing="1" cellPadding="1" border="0" ALIGN="center">
				<TR>
					<TD CLASS="FormInstructionRow" COLSPAN="2">
						Use the fields below to filter the <strong>$5</strong>, and click <strong>Select</strong> to view an instance.<BR>
						To add new <strong>$5</strong>, click the <strong>Add</strong> button. 
					</TD>
				</TR>
				<TR>
					<TD CLASS="fieldcell">${6:Filter Description}</TD>
					<TD CLASS="inputcell">
						<asp:TextBox id="txt${7:FilterType}" runat="server" CssClass="textbox" Text=""></asp:TextBox>
					</TD>
				</TR>
				<TR>
					<TD CLASS="CenterText" COLSPAN="2">
						<asp:Button id="btnList" runat="server" CssClass="button" Text="List"></asp:Button>&nbsp;
						<asp:Button id="btnAdd" runat="server" CssClass="button" Text="Add"></asp:Button>
					</TD>
				</TR>
				</TABLE><BR>
			</asp:Panel>
			<asp:DataGrid id="DG$2" runat="server" CssClass="grid" Width="80%" DataKeyField="ID" 
				AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" HorizontalAlign="Center" PageSize="20">
				<FooterStyle CssClass="GridFooter"></FooterStyle>
				<AlternatingItemStyle CssClass="GridAlternatingItem"></AlternatingItemStyle>
				<ItemStyle CssClass="GridItem"></ItemStyle>
				<HeaderStyle CssClass="GridHeader"></HeaderStyle>
				<PagerStyle CssClass="gridpager" PrevPageText="&lt; Previous " NextPageText=" Next &gt;"></PagerStyle>
				<Columns>
					<asp:ButtonColumn Text="Select" CommandName="Select"></asp:ButtonColumn>
					<asp:BoundColumn DataField="${8:DescriptionColumn}" SortExpression="$8" ReadOnly="True" HeaderText="${9:Description}">
						<HeaderStyle Wrap="False"></HeaderStyle>
						<ItemStyle Wrap="False"></ItemStyle>
					</asp:BoundColumn>
				</Columns>
			</asp:DataGrid>
		</asp:Panel>
	</FORM>
	</BODY>
	</HTML>

# A typical basic form page that allows editing a record
snippet page Edit page 
	<%-- Page Language="vb" AutoEventWireup="false" Codebehind="${1:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "general$", "", "")."General.aspx.vb"`}" Inherits="eikosonline.net.${2:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "general$", "", "")."General"`}" --%>
	<%@ Page Language="vb" AutoEventWireup="false" Codefile="$1.aspx.vb" Inherits="$2" %>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
	<HTML>
		<HEAD>
		<TITLE>${3:Entity - $1} General Details</TITLE>
		<LINK HREF="${4:../}Styles.CSS" type="text/css" rel="stylesheet">
	</HEAD>
	<BODY CLASS="centertext">
		<FORM ID="Form1" method="post" runat="server">
		<H3>$3 General Details</H3>
			<asp:Panel id="pnlError" align="center" runat="server" Visible="False">
			<TABLE class="formtable" id="Table1" cellSpacing="1" cellPadding="1" width="100%" align="center" border="1">
			<TR>
				<TD class="ValidationMessage" style="TEXT-ALIGN: center">
					<asp:Label id="lblError" runat="server" ForeColor="Red"></asp:Label>
				</TD>
			</TR>
			</TABLE>
			</asp:Panel>
			<asp:Panel id="pnlAll" runat="server">
				<TABLE class="formtable" id="Table1" cellSpacing="1" cellPadding="1" width="80%" border="0" ALIGN="center">
				<asp:Panel id="pnlSave1" runat="server" Visible="False">
				<TR>
					<TD CLASS="formButtonTable CenterText" COLSPAN="2">
						<asp:Button id="btnSave1" runat="server" CssClass="button" Text="Save"></asp:Button>
					</TD>
				</TR>
				</asp:Panel>
				<TR>
					<TD CLASS="fieldcell">${5:Field Name}</TD>
					<TD CLASS="inputcell"><asp:TextBox id="txt${6:Field}" runat="server" CssClass="textbox" Text=""></asp:TextBox></TD>
				</TR>

				<asp:Panel id="pnlSave2" runat="server" Visible="False">
				<TR>
					<TD CLASS="formButtonTable CenterText" COLSPAN="2">
						<asp:Button id="btnSave2" runat="server" CssClass="button" Text="Save"></asp:Button>
					</TD>
				</TR>
				</asp:Panel>
				</TABLE>
			</asp:Panel>
		</FORM>
	</BODY>
	</HTML>

# Used for sub-menus, a header page should display the entity"s status that it"s specific to.
snippet page Header page
	<%-- Page Language="vb" AutoEventWireup="false" Codebehind="${1:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "header$", "", "")."Header.aspx.vb"`}" Inherits="eikosonline.net.${2:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "header$", "", "")."Header"`}" --%>
	<%@ Page Language="vb" AutoEventWireup="false" Codefile="$1" Inherits="$2" %>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
	<HTML>
	<HEAD>
		<TITLE>$2 Header</TITLE>
		<LINK HREF="${3:../}Styles.CSS" type="text/css" rel="stylesheet">
	</HEAD>
	<BODY CLASS="centertext">
		<FORM ID="Form1" method="post" runat="server">
		<asp:Panel id="pnlError" CssClass="ErrorDiv" runat="server" Visible="False">
			<asp:Label id="lblError" runat="server"></asp:Label>
		</asp:Panel>
		<asp:Panel id="pnlAll" runat="server">
			<TABLE id="Table1" cellSpacing="0" cellPadding="1" width="100%" border="0">
			<TR>
				<TD CLASS="HeaderInformation">
					<strong>${4:Entity Description}</strong>&nbsp;<asp:Label id="lbl${5:FieldName1}" runat="server" Text=""></asp:Label>
				</TD>
				<TD CLASS="HeaderInformation" STYLE="text-align:right;">
					Status: <asp:Label id="lblStatus" runat="server" Text="Status"></asp:Label>
				</TD>
			</TR>
			</TABLE>
			<TABLE id="Table2" cellSpacing="0" cellPadding="1" width="100%" border="0">
			<TR>
				<TD CLASS="HeaderButtonRow">
					<asp:HyperLink id="hlGeneral" runat="server" Text="General" NavigateURL="$1General.aspx" Target="$2Detail"></asp:HyperLink>
				</TD>
				<TD CLASS="HeaderButtonRow" STYLE="width:10em">
					<asp:HyperLink id="hlList" runat="server" Text="Recall another $4" NavigateURL="${6:`substitute(substitute($1, ".aspx.vb", "List.aspx", ""), "header", "", "")`}" Target="_parent"></asp:HyperLink>
				</TD>
			</TR>
			</TABLE>
		</asp:Panel>
		</FORM>
	</BODY>
	</HTML>

# A basic page to create new instances of an Entity.
snippet page Add page
	<%-- Page Language="vb" AutoEventWireup="false" Codebehind="${1:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "add$", "", "")."Add.aspx.vb"`}" Inherits="eikosonline.net.${2:`substitute(substitute(Filename(), "\\.[a-zA-Z0-9]*$", "", ""), "add$", "", "")."Add"`}" --%>
	<%@ Page Language="vb" AutoEventWireup="false" Codefile="$1" Inherits="$2" %>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
	<HTML>
	<HEAD>
		<TITLE>${3:Entity Name} Add</TITLE>
		<LINK HREF="${4:../}Styles.CSS" type="text/css" rel="stylesheet">
	</HEAD>
	<BODY CLASS="centertext">
		<FORM ID="Form1" method="post" runat="server">
			<H3>$3 Add</H3>
			<asp:Panel id="pnlError" align="center" runat="server" Visible="False">
				<TABLE class="formtable" align="center" id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="1">
				<TR>
					<TD class="ValidationMessage" style="TEXT-ALIGN: center">
						<asp:Label id="lblError" runat="server" ForeColor="Red">
						</asp:Label>
					</TD>
				</TR>
				</TABLE>
			</asp:Panel>
			<asp:Panel id="pnlAll" runat="server">
				<TABLE class="formtable" id="Table1" cellSpacing="1" cellPadding="1" width="80%" border="0" ALIGN="center">
				trfield${5}
				<asp:Panel id="pnlAdd" runat="server" Visible="False">
				<TR>
					<TD CLASS="formButtonTable CenterText" COLSPAN="2">
						<asp:Button id="btnAdd" runat="server" CssClass="button" Text="Add"></asp:Button>
					</TD>
				</TR>
				</asp:Panel>
				</TABLE>
			</asp:Panel>
		</FORM>
	</BODY>
	</HTML>


